<ul>
<?php foreach($ar_videos as $video): ?>
<?php 
	$url = explode("&", $video->ds_url);
	$idVideo = explode('?v=', $url[0]);
	$idVideo = $idVideo[1];
	$url = str_ireplace('watch?v=', 'v/', $url[0]);
?>
<li class="fl" style="width: 140px">
	<a href="<?php echo $url; ?>" onclick="return false;" class="linkVideo">
		<img src="//i4.ytimg.com/vi/<?php echo $idVideo; ?>/default.jpg" />
		<?php echo $video->nm_item?>
	</a>
</li>

<!--  
<table>
	<tr>
		<td>
			<object height="340" width="560">
				<param value="<?php //echo $url; ?>&hl=pt-br&fs=1&autoplay=0" name="movie">
				<param value="true" name="allowFullScreen">
				<param value="always" name="allowscriptaccess">
				<embed height="340" width="560" 
				       allowfullscreen="true" allowscriptaccess="always" 
				       type="application/x-shockwave-flash" 
				       src="<?php //echo $url; ?>&hl=pt-br&fs=1&autoplay=0">
			</object>
		</td>
	</tr>
</table>
-->
<?php endforeach; ?>
</ul>

<div id="video" title="Visualizador de vídeo" align="center"></div>

<script type="text/javascript">
$(function(){
	$("#video").dialog({
		autoOpen: false,
		width: 630,
		height: 490,
		modal: true,
		resizable: false,
		buttons : {
			'Fechar' : function(){
				$(this).dialog('close').html("");
			}
		},
		close : function(){$(this).html("destroy");}
	});
	
	$(".linkVideo").click(function(){
		var texto = montarObject($(this).attr("href"));
		$("#video").dialog("open").html(texto);
	});
});

function montarObject(url)
{
	var htmlVideo;
	
	htmlVideo = "<object width='560' height='340'>";
	htmlVideo+= "<param name='movie' value='" + url + "&hl=pt-br&fs=1&autoplay=1'></param>";
	htmlVideo+= "<param name='allowFullScreen' value='true'></param>";
	htmlVideo+= "<param name='allowscriptaccess' value='always'></param>";
	htmlVideo+= "<embed src='" + url + "&hl=pt-br&fs=1&autoplay=1' type='application/x-shockwave-flash' ";
	htmlVideo+= "allowscriptaccess='always' allowfullscreen='true' width='560' height='340'>";
	htmlVideo+= "</embed></object>";
	
	return htmlVideo;
}
</script>
